/*===========================================================================================================================
	Wolf Prop Protection
		By Goluch
			DO NOT UPLOAD TO GARRYSMOD.ORG
			
			
	Section: Derma Tick Box
===========================================================================================================================*/
local Panel = { };

/*===========================================================================================================================
	Name: Panel.Init
	Purpose: Derma.
	Author: Goluch
===========================================================================================================================*/
function Panel:Init()
	self:SetSize( 16, 16 );
	self:SetPlayer();
	self:SetAction(1);
	self:SetValue( false );
end

/*===========================================================================================================================
	Name: Panel.SetPlayer
	Purpose: Derma.
	Author: Goluch
===========================================================================================================================*/
function Panel:SetPlayer( Player )
	self.SteamID = "global";
	self.Player = Player;
end

/*===========================================================================================================================
	Name: Panel.SetAction
	Purpose: Derma.
	Author: Goluch
===========================================================================================================================*/
function Panel:SetAction( ID )
	self.Action = ID;
end

/*===========================================================================================================================
	Name: Panel.SetValue
	Purpose: Derma.
	Author: Goluch
===========================================================================================================================*/
function Panel:SetValue( Value )
	Value = tobool( Value );
	if ( self.DisplayValue == Value ) then
		return;
	end
	
	if ( !Value ) then
		self:SetType( "close" );
	else
		self:SetType( "tick" );
	end
	
	self.DisplayValue = Value;
end

/*===========================================================================================================================
	Name: Panel.DoClick
	Purpose: Derma.
	Author: Goluch
===========================================================================================================================*/
function Panel:DoClick()
	local ID = -1;
	if ( self.Player ) then
		ID = self.Player:EntIndex();
	end
	
	local Value = 0;
	if ( self.Player ) and ( !WPP:GetTrust(LocalPlayer(),self.Player,self.Action) ) then
		Value = 1;
	elseif ( !self.Player ) and ( !WPP:GetTrustGlobal(LocalPlayer(),self.Action) ) then
		Value = 1;
	end
	
	RunConsoleCommand("wpp","trust",ID,self.Action,Value)
end

/*===========================================================================================================================
	Name: Panel.Think
	Purpose: Derma.
	Author: Goluch
===========================================================================================================================*/
function Panel:Think()
	if ( self.Player ) then
		self:SetValue( WPP:GetTrust(LocalPlayer(),self.Player,self.Action) );
	end
	
	if ( !self.Player ) then
		self:SetValue( WPP:GetTrustGlobal(LocalPlayer(),self.Action) );
	end
end

/*===========================================================================================================================
	Name: Panel.Paint
	Purpose: Derma.
	Author: Goluch
===========================================================================================================================*/
function Panel:Paint()
end

derma.DefineControl( "WPPCheckBox", "", Panel, "DSysButton" );